#include "player.h"

Player::Player()
{
    mMoveSpeed = 4;
    gravity = 0.5;
    vy=0;
    isJumping = false;
}
void Player::boundaryJudge()
{
    if(this->x()<20)
    {
        this->setX(20);
    }
    if(this->x()>GameDefine::ScreenWidth-this->boundingRect().width())

    {
        this->setX(GameDefine::ScreenWidth-this->boundingRect().width());
    }
    if(this->y()>GameDefine::ScreenHeight-this->boundingRect().height()-30)

    {
        this->setY(GameDefine::ScreenHeight-this->boundingRect().height()-30);

    }
    //单独检测左右两个凸出部分
    if(this->x()>1131&&this->y()>877)//1200,860
    {
        this->setPos(1130,879);
    }
    if(this->x()<174 && this->y() > 299 && this->y() <301)//40,250
    {
        this->setPos(175,300);
    }
}
void Player::down()
{
    vy += gravity;
    this->setY(this->y()+vy);
}
void Player::jump()
{
    if(!isJumping)
    {
        vy = 12;
        isJumping = true;
    }
}
Player::~Player()
{

}
